using System;
using System.Collections.Generic;

using FunctionInterface;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace Functions
{
	/// <summary>
	/// 拨打电话
	/// </summary>
	public class Dial : Activity, IProcessCommand
	{
		public event OutputMessageEventHandler OutputMessage;
		public FunctionInterface.Context Context {get; set;}
		
		public Dial ()
		{
		}
		
		public List<string> GetCommnads ()
		{
			List<string> cms = new List<string>();
			cms.Add("-d 拨打电话");
			return cms;
		}
		
		public void Process (string command)
		{
			string[] strs = command.Split(' ');
			DailNumber(strs[0]);
			if(OutputMessage != null)
			{
				OutputMessage(this, new OutputMessageEventArgs(){ Message = "通话结束。"});
			}
		}
		
		public bool Validate (string command)
		{
			return true;
		}
		
		public void DailNumber(string number)
		{
			var uri = Android.Net.Uri.Parse ("tel:" + number);
            //var intent = new Intent (Intent.ActionView, uri);  
			var intent = new Intent("android.intent.action.CALL", uri);
            //StartActivity (this);
		}
	}
	
	//    [Activity (Label = "LaunchPhoneDialer", MainLauncher = true)]
//    public class Activity1 : Activity
//    {
//
//        protected override void OnCreate (Bundle bundle)
//        {
//            base.OnCreate (bundle);
//
//            // Set our view from the "main" layout resource
//            SetContentView (Resource.Layout.Main);
//
//            // Get our button from the layout resource,
//            // and attach an event to it
//            Button button = FindViewById<Button> (Resource.Id.myButton);
//            
//            button.Click += delegate {
//                                
//                var uri = Android.Net.Uri.Parse ("tel:1112223333");
//                var intent = new Intent (Intent.ActionView, uri);  
//                StartActivity (intent);
//            };
//        }
//    }
}


